[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
isatty() Check for Character Device
#include <io.h>
int isatty(handle);
int handle; Handle of the device being tested
isatty() checks whether 'handle' is associated with a character
device (i.e., a terminal, console, printer, or serial port).
Returns: Non-zero if 'handle' is associated with a character
device; otherwise zero.
-------------------------------- Example ---------------------------------
The following statements determine if 'fhndl' is associated with a
character device. If not, they get the file pointer position.
#include <io.h>
#include <stdio.h>
int fhndl;
long position;
FILE *stream;
main()
{
stream = fopen("book.dat","w+");
fhndl = fileno(stream);
if (isatty(fhndl) == 0) {
position = ftell(fhndl);
printf("file position: %ld\n",position);
}
else
printf("handle associated with device");
}
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson